package com.team11.server.controller.admin;

import com.team11.server.pojo.PInformation;
import com.team11.server.service.admin.Admin_Insert_P_Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
@CrossOrigin
@RestController
@Api(tags = "管理员接口")
public class Admin_Insert_P_Controller {
    @Autowired
    private Admin_Insert_P_Service admin_insert_p_service;
    @ApiOperation("新增项目组")
    @PostMapping("/insert_p")
    public String insert_p(PInformation pInformation,String tName){
        String tN= tName;
        String[] tArray=tN.split("-");
        String tNumber=tArray[0];
        pInformation.setTId(admin_insert_p_service.SelTid(tNumber));
        String as=admin_insert_p_service.SelHaveP(pInformation.getPName());
        if (as.equals("1")){
            return admin_insert_p_service.insert_p(pInformation);
        }
        else return as;
    }
}
